<template>
    <div>
        {{ sum }}
        <button @click="ChangeSum">加1</button>
    </div> 
</template>

<script setup lang="ts" name="car">
   import { ref,computed,watch} from "vue";
   let  sum  = ref(0)
   function ChangeSum() {
    sum.value +=1
   }
   watch(sum,(newValue,oldValue)=>{
        console.log(`新数据${newValue}旧数据${oldValue}`);
        
   })
</script>

<style></style>